package File操作;

import java.io.File;
import java.util.Date;

public class 获取文件信息 {

    public static void main(String[] args) {
        File f = new File("E:/Test/1.txt");
        System.out.println("path: "+f.getPath());
        System.out.println("name: "+f.getName());
        //返回文件的大小（字节数）
        System.out.println("length: "+f.length());
        //返回上次修改时间：返回一个Long，可以转换为时间
        System.out.println("last modified: "+f.lastModified());
        System.out.println("last modified => Date: "+new Date(f.lastModified()));
        System.out.println("isFile: "+f.isFile());
        System.out.println("isDirectory: "+f.isDirectory());
    }
}
